//
//  TCM_AuctionListViewController.swift
//  TCM_TradingProject
//
//  Created by 吕春海 on 2018/8/27.
//  Copyright © 2018年 lvchunhai. All rights reserved.
//

import UIKit

class TCM_AuctionListViewController: TCM_BaseViewController,UITableViewDelegate,UITableViewDataSource {
    var autionTableview:UITableView!    
    let auctionArry = [["三七", "当归", "黄芪", "铁皮石斛","三七", "当归", "黄芪", "铁皮石斛", "当归", "黄芪", "铁皮石斛","三七", "当归", "黄芪", "铁皮石斛"], ["宁夏中卫", "陕西山阳", "黑龙江齐齐", "西藏日喀则","宁夏中卫", "陕西山阳", "黑龙江齐齐", "西藏日喀则", "陕西山阳", "黑龙江齐齐", "西藏日喀则","宁夏中卫", "陕西山阳", "黑龙江齐齐", "西藏日喀则"], ["1000", "230", "100030", "78", "1000", "230", "100030", "78", "230", "100030", "78", "1000", "230", "100030", "78"], ["1364", "326", "150000", "127", "1364", "326", "150000", "127", "326", "150000", "127", "1364", "326", "150000", "127"], ["炉白皮统", "家种三等", "家种二等", "松统", "炉白皮统", "家种三等", "家种二等", "松统", "家种三等", "家种二等", "松统", "炉白皮统", "家种三等", "家种二等", "松统"], ["264", "62", "5643", "125565", "264", "62", "5643", "125565", "62", "5643", "125565", "264", "62", "5643", "125565"]]
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.white
        self.title = "拍卖专场"
        
        setTabelView()

    }

    func setTabelView() {
        self.autionTableview = UITableView(frame: CGRect(x: 0, y: TCM_NavBarHeight() + 40, width: TCM_ScreenWidth, height: TCM_ScreenHeight - TCM_NavBarHeight() - TCM_SafeBottomAndTabbarHeight() - 40), style:UITableViewStyle.plain)
        self.autionTableview.backgroundColor = TCM_HexRGB(0xF0F0F0)
        self.autionTableview.separatorStyle = UITableViewCellSeparatorStyle.none
        self.autionTableview.showsVerticalScrollIndicator = false
        self.autionTableview.delegate = self
        self.autionTableview.dataSource = self
        
        
        self.view.addSubview(autionTableview)
        
        self.autionTableview.register(UINib.init(nibName: "TCM_HomeAuctionTableViewCell", bundle: nil), forCellReuseIdentifier: "AuctionCell")
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return auctionArry[0].count
    }
    
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 48
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        let cell = (autionTableview.dequeueReusableCell(withIdentifier: "AuctionCell", for: indexPath)) as! TCM_HomeAuctionTableViewCell
        cell.selectionStyle = .none
        cell.nameLabel.text = auctionArry[0][indexPath.row]
        cell.addressLabel.text = auctionArry[1][indexPath.row]
        cell.clapLable.text = auctionArry[2][indexPath.row]
        cell.latestLabel.text = auctionArry[3][indexPath.row]
        cell.varietiesLabel.text = auctionArry[4][indexPath.row]
        cell.numberLabel.text = auctionArry[5][indexPath.row]
        
        if indexPath.row % 2 == 0 {
            cell.contentView.backgroundColor = TCM_HexRGB(0xFBF7F5)
            cell.nameView.backgroundColor = TCM_HexRGB(0xFBF7F5)
            cell.clapView.backgroundColor = TCM_HexRGB(0xFBF7F5)
            cell.latestView.backgroundColor = TCM_HexRGB(0xFBF7F5)
            cell.varietiesView.backgroundColor = TCM_HexRGB(0xFBF7F5)
            cell.numberView.backgroundColor = TCM_HexRGB(0xFBF7F5)
        } else {
            cell.contentView.backgroundColor = UIColor.white
            cell.nameView.backgroundColor = UIColor.white
            cell.clapView.backgroundColor = UIColor.white
            cell.latestView.backgroundColor = UIColor.white
            cell.varietiesView.backgroundColor = UIColor.white
            cell.numberView.backgroundColor = UIColor.white
        }
        return cell
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let detailsVC = TCM_AutionDetailsViewController()
        self.navigationController?.pushViewController(detailsVC, animated: true)
    }
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
